# include <bits/stdc++.h>
using namespace std;

const int mike = 998244353;
long long q[10000010], s;

int main() {/* */
    //freopen("hoip.in", "r", stdin);
    //pen("hoip.out", "w", stdout);
    /*freopen("hoip.out", "w", stdout);*/
    int n, m;
    scanf("%d%d", &n, &m);
    if(n > m) swap(n, m);
    for(int i = n; i >= 1; i--) { 
        q[i] = 1ll * (n / i) * (m / i);
        for(int j = i + i; j <= n; j += i) q[i] -= q[j];
        (s += q[i] * i) %= mike;
    }
    printf("%d\n", (int) s % mike);
}
